package com.sxu.immutableDemo;

import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
 * 不可变集合
 */
public class Demo1 {
    public static void main(String[] args) {
        List<String> list = List.of("张三","李四","王五","赵六");
        System.out.println(list.get(0));
        System.out.println(list.get(1));
        System.out.println(list.get(2));
        System.out.println(list.get(3));
        System.out.println("--------------------------------------");
        for(String s : list){
            System.out.println(s);
        }
        System.out.println("--------------------------------------");
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
        System.out.println("--------------------------------------");
        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
    }
}
